import axios from 'axios'

const service = axios.create({
    baseURL: 'https://localhost:44300'
    , timeout: 5000
})

service.interceptors.request.use(
    config => {
        //todo: login token check
        return config;
    }
    , error => {
        return Promise.reject(error);
    }
)

service.interceptors.response.use(
    response => {
        const res = response.data

        if (res.code !== 1) {
            console.log(res.message)
        } else {
            return res;
        }
    }
    , error => {
        return Promise.reject(error)
    }
)

export default service;